<template>
  <div style="width: 20%;" class="center">
    <el-form :label-position="top" label-width="100px">
      <el-form-item label="用户名" prop="username">
        <el-input type="text" v-model="users.username" placeholder="请输入用户" clearable></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model="users.password" placeholder="请输入密码" show-password ></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password2">
        <el-input type="password" v-model="users.password2" placeholder="请输入密码" show-password ></el-input>
      </el-form-item>
      <el-button type="warning" @click="userRegister">注册</el-button>
      <el-button type="success" @click="userlogin">返回登录</el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "regist",
  data(){
    return{
      users:{}
    }
  },
  methods:{
    userRegister(username,password,password2){
      alert(this.users.username)
      this.axios.get("/user/register?username="+this.users.username+"&password="+this.users.password+"&password2="+this.users.password2).then((resp)=>{
        this.users=resp.data
        this.users={};
        this.$router.push("/user")
        this.$message.success("注册成功")
      }).catch((error)=>{
        this.$message.success("注册失败")
      })
    },
    userlogin(){
      this.$router.push("/user")
    }
  }
}
</script>

<style scoped>

</style>
